import {
	BseUrl
} from '../config/baseURL'
import {
	headerOptions
} from '../config/headerOptions'

export const imgUrl = BseUrl

export const http = async (options) => {
	// console.log(options, 'options====');
	const headerData = await headerOptions()
	// console.log(headerData,'headerData');
	// 在这里可以对请求头进行一些设置
	options.header = {
		...headerData,
		'Content-Type': 'application/json',
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: BseUrl.getInstance().getUrl().baseUrl + options.url || '',
			method: options.method || 'GET',
			data: options.data || {},
			header: options.header || {}
		}).then(data => {
			resolve(data.data)
		}).catch(error => {
			reject(error)
		})
	})
}